<!--#include virtual="/Common/Config.asp" -->
<!--#include virtual="/Common/conn.asp" -->
<!--#include virtual="/2010admin/Check_IsLogin.asp" -->
<!--#include virtual="/Common/Function.asp" -->
<!--#include file="Member_Inc.asp" -->
<!--#include virtual="/Common/MD5.asp" -->
<%
If Request.ServerVariables ("Request_Method")="POST" Then

	'禁止从网站外部提交数据
	Call Deny_OutSiteSubit()
	Return_Value = Change_Password()
	Select Case Return_Value
	   Case 0	Return_Message =  "密码修改失败!"
	   Case -9	Return_Message =  "旧密码错误!"
	   Case 1	Return_Message =  "密码修改成功!"
	End Select 

	AlertBox Return_Message,"javascript:history.go(-1)"


End If


	writebr Admin_UserId


'返回值  1 修改成功 0 失败 -9 旧密码错误
Function Change_Password()



	Admin_UserId = Session("Admin_UserId")
	UserPassword = MD5(Request.Form("UserPassword"))
	New_UserPassword1 = MD5(Request.Form("New_UserPassword1"))


	'On Error Resume Next

	Set cmd=Server.CreateObject("ADODB.command") 
	Set cmd.activeconnection = Conn

	cmd.commandtype = 4 
	cmd.commandtext = "usp_Change_Password"  'SP 修改密码

	cmd.parameters(1) = Admin_UserId
	cmd.parameters(2) = UserPassword

	cmd.parameters(3) = New_UserPassword1
	
	cmd.execute()
	
	Return_Value = cmd(4) '取得返回值

	If Err.Number>0 Then
		Return_Value = 0
	End If

	Set cmd = Nothing 

	Change_Password = Return_Value

End Function 

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/2010admin/css/default.css" type="text/css" rel="stylesheet">
<title><%=web_title%></title>
<script language="javascript" src="/js/prototype.js"></script>
<script language="javascript" >
function Jtrim(str)
{
        var i = 0;
        var len = str.length;
        if ( str == "" ) return( str );
        j = len -1;
        flagbegin = true;
        flagend = true;
        while ( flagbegin == true && i< len)
        {
           if ( str.charAt(i) == " " )
                {
                  i=i+1;
                  flagbegin=true;
                }
                else
                {
                        flagbegin=false;
                }
        }

        while  (flagend== true && j>=0)
        {
			if (str.charAt(j)==" ")
				{
						j=j-1;
						flagend=true;
				}
				else
				{
						flagend=false;
				}
        }

        if ( i > j ) return ("")

        trimstr = str.substring(i,j+1);
        return trimstr;
}


function check_form()
{
	  var UserPassword = $("UserPassword").value;
	  if (Jtrim(UserPassword) == "")
	  {
		window.alert("请填写旧密码！");
		$("UserPassword").focus();
		return (false);
	  }

	  var New_UserPassword1 = $("New_UserPassword1").value;
	  if (Jtrim(New_UserPassword1) == "")
	  {
		window.alert("请填写新密码！");
		$("New_UserPassword1").focus();
		return (false);
	  }

	  var New_UserPassword2 = $("New_UserPassword2").value;
	
	  if (Jtrim(New_UserPassword1) != Jtrim(New_UserPassword2))
	  {
		window.alert("两次输入的密码不一致！");
		$("New_UserPassword2").focus();
		return (false);
	  }
		
}
</script>
</head>
<body >
<table border="0" width="100%" cellSpacing="0" cellPadding="0">
  <tr>
    <td width="100%" height="5"></td>
  </tr>
  <tr>
    <td width="100%" align="center">
      <table border="0" width="98%" cellSpacing="0" cellPadding="0">
        <tr>
          <td width="*" align="center" valign="top">
            <table border="0" width="100%" cellSpacing="0" cellPadding="0">
              <tr>
                <td width="100%" height="5"></td>
              </tr>
            </table>
            <table border="0" width="100%" cellSpacing="0" cellPadding="0" class="lrbtline">
              <tr>
                <td width="100%" height="25" class="tbtop">修改用户密码</td>
              </tr>
              <tr>
                <td width="100%" align="center">
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                  <form name="form" method="post" action="" onSubmit="return check_form()">
                    <tr>
                      <td width="141" height="25">旧密码</td>
                      <td width="1056">
					  <input name="UserPassword" value="<%=UserPassword%>" type="password" id="UserPassword" size="20"  maxlength="20" >
					  </td>
                    </tr>
                    <tr>
                      <td width="141" height="25">新密码</td>
                      <td width="1056"><input name="New_UserPassword1" type="password" id="New_UserPassword1" size="20" maxlength="20" ></td>
                    </tr>
                    <tr>
                      <td width="141" height="25">再输一遍新密码</td>
                      <td width="1056"><input name="New_UserPassword2" type="password" id="New_UserPassword2" size="20" maxlength="20"></td>
                    </tr>
                    <tr>
                      <td height="25"></td>
                      <td><input type="submit" name="submit1" value="提交" class="button">&nbsp;<input type="button" name="reset" value="返回" class="button" onClick="history.back();">
                        <input name="UserID" type="hidden" id="UserID" value="<%=UserID%>"></td>
                    </tr>
                  </form>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td width="100%" height="5"></td>
  </tr>
</table>
</body>
</html>

